<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
   pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="support.*,java.util.*"%>

<html>
<head>
<link rel="stylesheet" type="text/css" href="layout.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Country of Residence</title>

<%
   student applicant = (student) session.getAttribute("applicant");
   applicant.setCitizenship(Integer.parseInt(request
         .getParameter("citizenship")));
%>

</head>
<body>
   <p>
      Name:
      <%=applicant.name.toString()%><br> Citizenship:
      <%=applicant.getCountryVector().get(applicant.getCitizenship())%></p>
   <hr>

   <p><b>Please choose your country of residence:</b></p>
   <a href="address.jsp?residence=<%=applicant.getCitizenship()%>">Same
      country as citizenship (<%=applicant.getCountryVector().get(applicant.getCitizenship())%>)
   </a>
   <br>
   <br>
<table border="1">
    <%
      int size = applicant.getCountryVector().size(), rows, cell1, cell2, cell3;

      if (applicant.getCountryVector().size() % 3 == 0)
        rows = (int) (size / 3);
      else
        rows = (int) (size / 3) + 1;

      for (int i = 0; i < rows; i++) {
        cell1 = i;
        cell2 = i + rows;
        cell3 = i + 2 * rows;
    %>
    <tr>
      <td><a href="address.jsp?residence=<%=cell1%>"><%=applicant.getCountryVector().get(cell1)%></a></td>
      <%
        if (cell2 < size) {
      %>
      <td><a href="address.jsp?residence=<%=cell2%>"><%=applicant.getCountryVector().get(cell2)%></a></td>
      <%
        }
          if (cell3 < size) {
      %>
      <td><a href="address.jsp?residence=<%=cell3%>"><%=applicant.getCountryVector().get(cell3)%></a></td>
      <%
        }
      %>
    </tr>
    <%
      }
    %>
  </table>





</body>
</html>